import 'package:flutter/material.dart';
import 'package:x3_charts_core/chart_painter/wave_loading_painter.dart';

///**
///* Description: 水滴图（有进度的）
///*/
class WaveLoadingWidget extends StatefulWidget {
  final String text;

  final double fontSize;

  final Color backgroundColor;

  final Color foregroundColor;

  final Color waveColor;

  ///水滴中水的占比
  final double proportion;

  WaveLoadingWidget({
    @required this.text,
    @required this.fontSize,
    @required this.backgroundColor,
    @required this.foregroundColor,
    @required this.waveColor,
    @required this.proportion,
  }) {
    assert(text != null);
    assert(fontSize != null && fontSize > 0);
    assert(proportion != null && proportion >= 0 && proportion <= 1);
  }

  @override
  _WaveLoadingWidgetState createState() => _WaveLoadingWidgetState(text: text, fontSize: fontSize, backgroundColor: backgroundColor, foregroundColor: foregroundColor, waveColor: waveColor, proportion: proportion);
}

class _WaveLoadingWidgetState extends State<WaveLoadingWidget> with SingleTickerProviderStateMixin {
  final String text;

  final double fontSize;

  final Color backgroundColor;

  final Color foregroundColor;

  final Color waveColor;

  final double proportion;

  _WaveLoadingWidgetState({
    @required this.text,
    @required this.fontSize,
    @required this.backgroundColor,
    @required this.foregroundColor,
    @required this.waveColor,
    @required this.proportion,
  });

  @override
  Widget build(BuildContext context) {
    return CustomPaint(
      painter: WaveLoadingPainter(text: text, fontSize: fontSize, backgroundColor: backgroundColor, foregroundColor: foregroundColor, waveColor: waveColor, proportion: proportion),
    );
  }
}
